/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dsigner.tools;

import java.io.Console;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Technik
 */
public class StringTool {

    boolean found = false;
    Console console;

    public StringTool() {
    }

    public void findStringLine(String line, String regex) {
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(line);

        while (matcher.find()) {
            found = true;
        }
    }
    
    public void findStringFile(String line, String regex) {
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(line);

        while (matcher.find()) {
            console.format("I found the text" +
                    " \"%s\" starting at " +
                    "index %d and ending at index %d.%n",
                    matcher.group(),
                    matcher.start(),
                    matcher.end());
            found = true;
        }
    }
}
